using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.PersonDomain;
using ShivamEMR.Model.DataInterfaces.PersonDataInterf;
using ShivamEMR.Model;
using ShivamEMR.Web.Models;
//using ShivamEMR.Web.Areas.Person.Models;

namespace ShivamEMR.Web.Areas.Person.Controllers
{   
    public class MaritalStatusController : Controller
    {
		private readonly IMaritalStatusRepository maritalstatusRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public MaritalStatusController() 
        {
            maritalstatusRepository = Registry.RepositoryFactory.GetMaritalStatusRepository();
        }

        public MaritalStatusController(IMaritalStatusRepository maritalstatusRepository)
        {
			this.maritalstatusRepository = maritalstatusRepository;
        }

        //
        // GET: /MaritalStatus/
        [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        public ViewResult Index()
        {
            return View(maritalstatusRepository.All);
        }

        //
        // GET: /MaritalStatus/Details/5
        [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        public ViewResult Details(int id)
        {
            return View(maritalstatusRepository.Find(id));
        }

        //
        // GET: /MaritalStatus/Create
        [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /MaritalStatus/Create
        [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        [HttpPost]
        public ActionResult Create(MaritalStatus maritalstatus)
        {
            if (ModelState.IsValid) {
                maritalstatusRepository.Create(maritalstatus);
                maritalstatusRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /MaritalStatus/Edit/5
 [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        public ActionResult Edit(int id)
        {
             return View(maritalstatusRepository.Find(id));
        }

        //
        // POST: /MaritalStatus/Edit/5
        [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        [HttpPost]
        public ActionResult Edit(MaritalStatus maritalstatus)
        {
            if (ModelState.IsValid) {
                maritalstatusRepository.Update(maritalstatus);
                maritalstatusRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /MaritalStatus/Delete/5
 [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        public ActionResult Delete(int id)
        {
            return View(maritalstatusRepository.Find(id));
        }

        //
        // POST: /MaritalStatus/Delete/5
        [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
           // maritalstatusRepository.Delete(id);
            var mstatus = maritalstatusRepository.Find(id);
            maritalstatusRepository.Delete(mstatus);
            maritalstatusRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

